package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmFda;
import com.ruoyi.web.admin.service.ITdmFdaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * FDA数据库管理Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/admin/TdmFda")
public class TdmFdaController extends BaseController
{
    @Autowired
    private ITdmFdaService tdmFdaService;

    /**
     * 查询FDA数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmFda tdmFda)
    {
        startPage();
        List<TdmFda> list = tdmFdaService.selectTdmFdaList(tdmFda);
        return getDataTable(list);
    }

    /**
     * 导出FDA数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:export')")
    @Log(title = "FDA数据库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmFda tdmFda)
    {
        List<TdmFda> list = tdmFdaService.selectTdmFdaList(tdmFda);
        ExcelUtil<TdmFda> util = new ExcelUtil<TdmFda>(TdmFda.class);
        util.exportExcel(response, list, "FDA数据库管理数据");
    }

    /**
     * 获取FDA数据库管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmFdaService.selectTdmFdaById(id));
    }

    /**
     * 新增FDA数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:add')")
    @Log(title = "FDA数据库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmFda tdmFda)
    {
        return toAjax(tdmFdaService.insertTdmFda(tdmFda));
    }

    /**
     * 修改FDA数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:edit')")
    @Log(title = "FDA数据库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmFda tdmFda)
    {
        return toAjax(tdmFdaService.updateTdmFda(tdmFda));
    }

    /**
     * 删除FDA数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmFda:remove')")
    @Log(title = "FDA数据库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmFdaService.deleteTdmFdaByIds(ids));
    }
}
